package cn.znzz.cjm.mapper;

import cn.znzz.cjm.domain.Permission;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author chenjiangmin
 * @since 2021-12-16
 */
@Mapper
public interface PermissionMapper extends BaseMapper<Permission> {

    @Select("SELECT\n" +
            "\tp.* \n" +
            "FROM\n" +
            "\tt_user_role ur\n" +
            "\tLEFT JOIN t_role_permission rp ON ur.role_id = rp.role_id\n" +
            "\tLEFT JOIN t_permission p ON rp.permission_id = p.id \n" +
            "WHERE\n" +
            "\tuser_id = #{id}")
    List<Permission> selectPermisson(Long id);
}
